package controller

import (
	"jtdevice/api/device/dto"
	"jtdevice/api/device/model"
	"jtdevice/pkg/ctx"

	"github.com/gin-gonic/gin"
)

type Online struct {
}

func (o *Online) ListHandler(c *gin.Context) {
	var p dto.Where
	if err := c.ShouldBind(&p); err != nil {
		ctx.JSONWriteError(err, c)
		return
	}
	var data []model.Online
	total, _ := p.DbModelWhere(&model.Online{}).Find(&data)
	ctx.JSONWrite(gin.H{"total": total, "data": data}, c)
}

func (o Online) Router(r *gin.RouterGroup) {
	r.GET("/list", o.ListHandler)
}
